package com.zc.controller;

import com.zc.enums.InfoEnum;
import com.zc.property.InfoProperties;
import com.zc.property.LifeProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

@RestController
public class HelloController {
    public static final Logger log= LoggerFactory.getLogger(HelloController.class);

    @Autowired
    private InfoProperties infoProperties;

    @Autowired
    private LifeProperties lifeProperties;

    @Autowired
    MessageSource messageSource;
   @GetMapping("/hello")
    public String hello() {
        Locale locale = LocaleContextHolder.getLocale();
        String msg = messageSource.getMessage(InfoEnum.HELLO.getMsg(), null, locale);
        return msg;
    }
    @GetMapping("info")
    public String info() {
        return infoProperties.toString();
    }

    @GetMapping("life")
    public String life() {
        return lifeProperties.toString();
    }

}
